package com.ophiux.servlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



public class PropertyUtil {
	private static Logger logger = LoggerFactory.getLogger(PropertyUtil.class);
	public static String getResWxValue(String property){
		// 读取配置文件
		Properties properties = new Properties();
		InputStream inputStream = PropertyUtil.class.getResourceAsStream("/weixin.properties");
		BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream));
		String value=null;
		try {
			properties.load(bf);
			value = properties.getProperty(property);
			value = new String(value.getBytes("ISO-8859-1"), "utf-8");
			logger.info("读取配置文件{}信息属性 {}：{}",new Object[]{"weixin.properties",property,value});
		} catch (IOException e) {
			e.printStackTrace();
		}
		return value;
	}
	
	public static String getResAliValue(String property){
		// 读取配置文件
		Properties properties = new Properties();
		InputStream inputStream = PropertyUtil.class.getResourceAsStream("/alipay.properties");
		BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream));
		String value=null;
		try {
			properties.load(bf);
			value = properties.getProperty(property);
			value = new String(value.getBytes("ISO-8859-1"), "utf-8");
			logger.info("读取配置文件{}信息属性 {}：{}",new Object[]{"alipay.properties",property,value});
		} catch (IOException e) {
			e.printStackTrace();
		}
		return value;
	}
	
	public static void main(String[] args) {
		System.out.println(PropertyUtil.getResWxValue("appid"));
	}
}
